import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/core/utils/user_manager.dart';
import 'package:enterprise_v6_app/app/data/entities/task/patrol_scheme_entity.dart';
import 'package:enterprise_v6_app/router/app_pages.dart';
import 'package:get/get.dart';

class InvestigationPlanController extends GetxController {
  /// 获取数据
  Future<List<PatrolSchemeEntity>> getListData(int pageNum, int pageSize) async {
    // 没有登录不进行接口调用
    if (!UserManager.isLoggedIn) {
      return [];
    }
    // 查询排查计划列表
    final res = await HttpUtil().generateGetRequest<List<PatrolSchemeEntity>>(
      Interface.checkTheListOfTroubleshootingPlans,
      queryParameters: {
        'pageNum': pageNum,
        'pageSize': pageSize,
      },
    ).execute();
    List<PatrolSchemeEntity>? data;
    res.onSuccess((result) {
      data = result.data;
    });
    return data ?? [];
  }

  // 进入巡检详情
  void goInspectionDetails(String? id) {
    // 进入单元
    Get.toNamed(AppRoutes.planUnitPage, arguments: id);

    // 进入任务
    // Get.toNamed(AppRoutes.runTaskDetail, arguments: {'id': id, 'type': 1});
  }
}

/// 开发测试类
class TestClass {}
